package com.rober.algorithm;

/**
 * @for 单例模式——懒汉式 111
 * @author roberluo
 *
 */
public class SingleModelLazyMan {


	// 方法私有
	private  SingleModelLazyMan() {};
	
	// 添加volatile，防止指令重排
    private volatile static SingleModelLazyMan singleModelLazyMan;
    
    private static SingleModelLazyMan run() {
    	// 双重检测
    	if(singleModelLazyMan == null) {
    		// 上锁
    		synchronized (singleModelLazyMan) {
    			if (singleModelLazyMan == null) {
    				singleModelLazyMan = new SingleModelLazyMan();
				}
			}
    		
    	}
    		
		return singleModelLazyMan;
	}
}
